<template>
  <div :class="['halert', `halert-${type}`, `halert-${size}`]">
    <div class="halert--left-line"></div>
    <h1 @click="$emit('toDetail')" class="halert--h1 ellipsis-2" :style="{width: tip ? '86%' : '96%'}">{{ title }}</h1>
    <div class="halert--tip" v-if="tip">{{ tip }}</div>
    <div class="halert--footer" v-if="!showDesc">
      <span>事件编号</span>
      <a-divider type="vertical"></a-divider>
      <span>{{ no || '无' }}</span>
      <span class="halert--footer-blue">
        <span>已发 {{ sendNum }}</span>
        <a-divider type="vertical"></a-divider>
        <span>已回复 {{ replyNum }}</span>
      </span>
    </div>
    <div v-else-if="showDescribe" class="halert--footer ellipsis-2" style="margin-top: -8px;line-height: 1.2;">
      <p>{{ desc }}</p>
    </div>
    <div class="halert--footer ellipsis-2" style="margin-top: 13px" v-else>
      <p>{{ desc }}</p>
    </div>

    <a-button @click="$emit('toDetail')" v-if="showDetailBtn" size="small" :type="type" :class="['halert--footer-btn', type =='primary' ? 'ant-btn-b' : '']">
      查看详情
    </a-button>
  </div>
</template>
<script>
export default {
  name: 'HAlert',
  props: {
    size: {
      type: String,
      default: 'default'
    },
    type: {
      type: String,
      default: 'primary'
    },
    title: {
      type: String,
      default: '事件标题事件标题事件标题事件标题事件标题事件标题事件标题事件标题'
    },
    tip: {
      type: String,
      default: ''
    },
    desc: {
      type: String,
      default: ''
    },
    sendNum: {
      type: [String, Number],
      default: 0
    },
    replyNum: {
      type: [String, Number],
      default: 0
    },
    no: {
      type: String,
      default: '202262101'
    },
    showDesc: {
      type: Boolean,
      default: false
    },
    showDetailBtn: {
      type: Boolean,
      default: true
    },
    showDescribe: {
      type: Boolean,
      default: true
    },
    hideTag: {
      type: Boolean,
      default: true
    }
  }
};
</script>
<style lang="less" scoped>
.halert {
  padding: 9px 16px;
  box-sizing: border-box;
  box-shadow: 0px 3px 29px 0px rgba(196,203,214,0.1000);
  position: relative;
  border-radius: 5px;
  overflow: hidden;
  margin-top: 14px;
  min-height: 90px;
  &:first-child {
    margin-top: 0;
  }
  &.halert-large {
    margin-bottom: 24px;
    padding: 9px 20px;
    &:last-child {
      margin-bottom: 0;
    }
    > h1 {
      font-size: 16px;
    }
    .halert--footer {
      font-size: 14px;
    }
  }

  .halert--left-line {
    width: 4px;
    height: 90%;
    border-radius: 20px;
    position: absolute;
    left: 17px;
    top: 5%;
  }

  > h1 {
    font-size: 15px;
    font-weight: 400;
    color: #0A1629;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    width: 86%;
    margin-left: 14px;
  }

  .halert--tip {
    width: 38px;
    height: 18px;
    position: absolute;
    right: 0;
    top: 0;
    font-size: 12px;
    font-weight: 400;
    color: #FFFFFF;
    line-height: 16px;
    text-align: center;
  }

  .halert--footer {
    margin-top: 13px;
    color: #91929E;
    font-size: 12px;
    margin-left: 14px;
  }

  .halert--footer-blue {
    margin-left: 20px;
    color: #3F8CFF;
    > span {
      cursor: pointer;
    }
  }

  .halert--footer-btn {
    position: absolute;
    right: 16px;
    bottom: 6px;
    font-size: 12px;
  }

  &.halert-primary {
    background: rgba(63, 140, 255, 0.0500);
    .halert--left-line {
      background: #3F8CFF;
    }
    .halert--tip {
      background: #3F8CFF;
      border: 1px solid #3184FA;
    }
  }

  &.halert-danger {
    background: rgba(246, 8, 8, 0.0500);
    .halert--left-line {
      background: #FF0000;
    }
    .halert--tip {
      background: #FF0000;
      border: 1px solid #FF0000;
    }
    .halert--footer-blue {
      color: #FF0000;
    }
  }

  .halert--h1 {
    height: 42px;
    cursor: pointer;
    &:hover {
      color: #3184FA;

    }
  }

  @media (max-width: 1600px) {
    .halert--left-line {
      left: 0;
    }
    > h1{
      margin-left: 0;
    }
    .halert--footer {
      margin-left: 0;
    }
  }
}
</style>
